﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyAuthCore.Api.Filters;

namespace MyAuthCore.Api.Controllers
{
    [Route("api/[controller]")]
    public class ValuesController : AuthFilter
    {
        //int count = 0;
        // GET api/values
        [HttpGet]
        public IEnumerable<string> Get()
        {
            //this.HttpContext.Session.SetString("hai", "测试水水水水水水水水水水"+ count++);
            return new string[] { "set", "set" };
        }

        // GET api/values/5
        [HttpGet("{id}")]
        public string Get(int id)
        {
       
            string value= this.HttpContext.Session.GetString("hai");
            if(string.IsNullOrEmpty(value) )
            {
                return "无效啦";
            }
            else
            {
                return value;
            }
        }

        // POST api/values
        [HttpPost]
        public void Post([FromBody]string value)
        {
        }

        // PUT api/values/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
        }
    }
}
